package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.app.APPServiceTemporaryCarListPageDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateFixedVehiclePageDTO;
import com.itlong.cloud.POJO.DTO.property.CarIssueDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyCarOpenMonthCardDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyCarRenewMonthCardDTO;
import com.itlong.cloud.POJO.VO.app.AppServiceTemporaryCarListVO;
import com.itlong.cloud.POJO.VO.operate.OperateFixedVehicleInfoVO;
import com.itlong.cloud.project.property.IPropertyCarMonthCardServiceClient;
import com.itlong.cloud.property.service.IPropertyCarMonthCardService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *      物业管理-车辆的月卡管理暴露接口实现类
 * </desc>
 *
 * @createDate 2018/11/05
 */
@RestController
public class PropertyCarMonthCardResource implements IPropertyCarMonthCardServiceClient {

    @Autowired
    private IPropertyCarMonthCardService iPropertyCarMonthCardService;

    /**
     * <desc>
     *      车辆开通或修改月卡
     * </desc>
     *
     * @param propertyCarOpenMonthCardDTO 月卡开通、修改DTO
     * @return 受影响行数
     * @throws Exception
     * @author wangzhi
     * @createDate 2018/11/05
     */
    @Override
    @PostMapping(path = "property/parking/openMonthCard")
    public Integer openMonthCard(@RequestBody PropertyCarOpenMonthCardDTO propertyCarOpenMonthCardDTO) throws Exception {
        return iPropertyCarMonthCardService.openMonthCard(propertyCarOpenMonthCardDTO);
    }

    /**
     * <desc>
     *      车辆月卡续费
     * </desc>
     *
     * @param propertyCarRenewMonthCardDTO 月卡续费DTO
     * @return 车牌凭证发行DTO
     * @author wangzhi
     * @createDate 2018/11/05
     */
    @Override
    @PostMapping(path = "property/parking/renewMonthCard")
    public CarIssueDTO renewMonthCard(@RequestBody PropertyCarRenewMonthCardDTO propertyCarRenewMonthCardDTO, @RequestParam("mark") String mark) throws Exception {
        return iPropertyCarMonthCardService.renewMonthCard(propertyCarRenewMonthCardDTO, mark);
    }

    /**
     * <desc>
     *      固定车辆信息分页查询
     * </desc>
     *
     * @param operateFixedVehiclePageDTO 分页查询参数
     * @return
     * @author Qiang.S
     * @createDate 2018/11/05
     */
    @Override
    @PostMapping(path = "property/parking/getFixedVehiclePage")
    public Page<OperateFixedVehicleInfoVO> getFixedVehiclePage(@RequestBody OperateFixedVehiclePageDTO operateFixedVehiclePageDTO) throws Exception {
        return iPropertyCarMonthCardService.getFixedVehiclePage(operateFixedVehiclePageDTO);
    }

    /**
     * <desc>
     *      获取临时车辆列表
     * </desc>
     *
     * @param appServiceTemporaryCarListPageDTO
     * @return
     * @author Qiang.S
     * @createDate 2018/11/07
     */
    @Override
    @PostMapping(path = "property/parking/temporaryCarList")
    public Page<AppServiceTemporaryCarListVO> temporaryCarList(@RequestBody APPServiceTemporaryCarListPageDTO appServiceTemporaryCarListPageDTO) throws Exception {
        return iPropertyCarMonthCardService.temporaryCarList(appServiceTemporaryCarListPageDTO);
    }

    /**
     * <desc>
     *      删除临时车辆通行记录
     * </desc>
     *
     * @param plateNumber 车牌
     * @param userId 用户编号
     * @return
     * @author Qiang.S
     * @createDate 2018/11/07
     */
    @Override
    @PostMapping(path = "property/parking/deleteTemporaryCar")
    public Integer deleteTemporaryCar(@RequestParam("plateNumber") String plateNumber, @RequestParam("userId") String userId) throws Exception {
        return iPropertyCarMonthCardService.deleteTemporaryCar(plateNumber,userId);
    }

    /**
     * <desc>
     *      清除临时车辆列表
     * </desc>
     *
     * @param userId 用户编号
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/06/25
     */
    @Override
    @PostMapping(path = "property/parking/deleteAllTemporaryCar")
    public Integer deleteAllTemporaryCar(@RequestParam("userId") String userId) throws Exception {
        return iPropertyCarMonthCardService.deleteAllTemporaryCar(userId);
    }
}
